import request from '@/utils/request'

// 获取模型域顶层域列表
export const getRootDomainListApi = (data) =>
  request.get('/core/vom/model/design/root-domain/list', data)

// 获取模型域子域列表
export const getChildDomainListApi = (id) =>
  request.get(`/core/vom/model/design/child-domain/list?parentId=${id}`)

// 上移模型域
export const upDomainApi = (data) =>
  request.post('/core/vom/model/design/domain/move-up', data, {
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
  })

// 下移模型域
export const downDomainApi = (data) =>
  request.post('/core/vom/model/design/domain/move-down', data, {
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
  })
// 查询业务模型列表
export const getTabelListApi = (id) =>
  request.get(`/core/vom/model/design/biz-class/list?domainId=${id}`)

// 查询未建模数据库表列表
export const getUnmodeledTabelListApi = (id) =>
  request.get(`/core/vom/model/design/unmodeled/biz-table/list?domainId=${id}`)

// 新增模型域顶层域列表
export const addRootDomainApi = (data) =>
  request.post('/core/vom/model/design/root-domain', data, {
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
  })

// 创建业务模型
export const addBusinessModelApi = (data) =>
  request.post('/core/vom/model/design/biz-class', data, {
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
  })
// 批量创建业务模型
export const addBusinessModelsApi = (domainId, arr) =>
  request.post(
    `/core/vom/model/design/biz-class/batch-save?domainId=${domainId}`,
    arr,
    {
      headers: { 'Content-Type': 'application/json' }
    }
  )

// 删除业务模型
export const delBusinessModelApi = (bizModelId) =>
  request.post(
    `/core/vom/model/design/biz-class/delete?bizModelId=${bizModelId}`
  )

// 查询业务模型信息
export const getBusinessDataApi = (id) =>
  request.get(`/core/vom/model/design/biz-class?bizModelId=${id}`)

// 修改业务模型
export const editBusinessModelAApi = (data) =>
  request.post('/core/vom/model/design/biz-class/put', data, {
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
  })

// 查询业务模型属性列表
export const getPropertyListApi = (id) =>
  request.get(`/core/vom/model/design/biz-class/field/list?bizModelId=${id}`)

// 同步业务模型属性
export const syncModelPropertyApi = (data) =>
  request.post('/core/vom/model/design/biz-class/field/sync', data, {
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
  })

// 删除属性字段
export const delModelPropertyApi = (id) =>
  request.post(
    `/core/vom/model/design/biz-class/field/delete?bizFieldId=${id}`
  )

// 创建业务模型属性
export const addModelPropertyApi = (data) =>
  request.post('/core/vom/model/design/biz-class/field', data, {
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
  })

// 查询业务模型属性信息
export const getPropertyModelApi = (id) =>
  request.get(`/core/vom/model/design/biz-class/field?bizFieldId=${id}`)

// 修改业务模型属性
export const editModelPropertyApi = (data) =>
  request.post('/core/vom/model/design/biz-class/field/put', data, {
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
  })

// 查询业务模型索引列表
export const getIndexListApi = (id) =>
  request.get(`/core/vom/model/design/biz-class/index/list?bizModelId=${id}`)

// 查询属性类型字典下拉框列表
export const getPropTypeListApi = () =>
  request.get('/core/dictionary/combo-item/list?dictType=PropType')

// 创建业务模型索引
export const addIndexApi = (data) =>
  request.post('/core/vom/model/design/biz-class/index', data, {
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
  })

// 修改业务模型索引
export const editIndexApi = (data) =>
  request.post('/core/vom/model/design/biz-class/index/put', data, {
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
  })
// 删除业务模型索引
export const delIndexApi = (id) =>
  request.post(
    `/core/vom/model/design/biz-class/index/delete?bizIndexId=${id}`
  )

// 查询业务模型索引信息
export const getIndexDataApi = (id) =>
  request.get(`/core/vom/model/design/biz-class/index?bizIndexId=${id}`)

// 查询业务模型数据库变更语句
export const getExecuteSqlApi = (id) =>
  request.get(`/core/vom/model/design/biz-class/execute-sql?bizModelId=${id}`)

// 查询业务模型数据库建表语句
export const getCreateSqlApi = (id) =>
  request.get(`/core/vom/model/design/biz-class/create-sql?bizModelId=${id}`)

// 执行业务模型数据库变更
export const executeSqlApi = (data) =>
  request.post('/core/vom/model/design/biz-class/execute-sql', data, {
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
  })
